package com.qly.jsoup.service.web;

import com.alibaba.fastjson.JSON;
import com.qly.jsoup.service.util.JsoupUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * Created by Andy ye on 2018/8/22.
 */
@RestController
@RequestMapping("/jsoup")
public class JsoupController {

    @Autowired
    JsoupUtil jsoupUtil;


    @RequestMapping("/getZhilianJobs")
    @ResponseBody
    private String getZhilianJobs(HttpServletRequest request, HttpSession session) {

        String[] area = new String[]{"489", "703", "530", "538", "765"};
        String[] areaName = new String[]{"全国", "青岛", "北京", "上海", "深圳"};

        String[] jobName = new String[]{"java", "大数据", "python", "nodejs"};
        Integer maxPage = 5;

        Map<String, Object> resultMap = jsoupUtil.getZhilianJobsInfo(area, jobName, maxPage);
        String result = JSON.toJSONString(resultMap);

        return result;
    }

    @RequestMapping("/getZhilianJobsJson")
    @ResponseBody
    private String getZhilianJobsJson(HttpServletRequest request, HttpSession session) {

        String[] area = new String[]{"489", "703", "530", "538", "765"};
        String[] jobName = new String[]{"java", "大数据", "python", "nodejs"};
        Integer maxPage = 5;

        return jsoupUtil.getZhilianJobsJson(area, jobName, maxPage);
    }

    @RequestMapping("/getVipComList")
    @ResponseBody
    private Map<String, Object> getVipComList(HttpServletRequest request, HttpSession session) {

        Map<String, Object> resultMap = jsoupUtil.getVipComList();
        return resultMap;

    }
}
